package org.oschina.api.user.user.plugin;

import org.oschina.api.user.user.dao.UserDAO;
import org.oschina.api.user.user.model.User;
import org.oschina.plugin.AbstractPlugin;
import org.oschina.plugin.annotation.Plugin;
import org.springframework.beans.factory.annotation.Autowired;

@Plugin
public class UserLogoutDataHandlePlugin extends AbstractPlugin {

	@Autowired
	private UserDAO userDAO;
	
	@Override
	public String getExplain()
	{
		return "用户下线数据处理插件";
	}
	
	@Override
	public void logout(User user)
	{
		userDAO.updateOnline(user.getId(), false);
		userDAO.updateLastLogin(user.getId(),user.getLast_login());
	}

}